package exam.business.service;

import exam.common.constant.ResultPort;
import exam.common.key.KeyStudent;
import exam.common.util.LongUtils;
import exam.common.util.NullCheckUtil;
import exam.model.dao.TStudentDAO;
import exam.model.entity.TStudentEntity;
import exam.system.business.AbstractService;
import exam.system.business.BusinessServiceInfo;



public class StudentGetService extends AbstractService {
	// tStudentDAO
	private TStudentDAO tStudentDAO = new TStudentDAO();
	
	@Override
	public String executeService(BusinessServiceInfo serviceInfo)
			throws Exception {
		// TODO Auto-generated method stub
		String studentCd = serviceInfo.getString(KeyStudent.T_STUDENT_CD);
		String studentId = serviceInfo.getString(KeyStudent.T_STUDENT_ID);
		TStudentEntity tStudentEntity = null;
		if(NullCheckUtil.isNotNull(studentCd)) {
			tStudentEntity = tStudentDAO.selectByCd(studentCd);
		} else {
			tStudentEntity = tStudentDAO.selectByPk(LongUtils.convertStringToLong(studentId));
		}
		// Lấy thông tin sinh viên
		if(NullCheckUtil.isNull(tStudentEntity)) {
			return ResultPort.NONE;
		}
		serviceInfo.put(KeyStudent.T_STUDENT_ENTITY, tStudentEntity);
		return ResultPort.SUCCESS;
	}

}
